//
//  HMTitleBtn.m
//  网易彩票01
//
//  Created by Macx on 16/2/21.
//  Copyright © 2016年 Macx. All rights reserved.
//

#import "HMTitleBtn.h"

@implementation HMTitleBtn

-(void)layoutSubviews{
  //通过此方法对button中的titlelabel和imageview进行重新布局
    
    [super layoutSubviews];
    CGFloat btnWidth=self.frame.size.width;
    CGFloat btnHeight=self.frame.size.height;
    
    CGFloat imgwidth=self.imageView.frame.size.width;
    CGFloat imgheight=self.imageView.frame.size.height;
    
    CGFloat margin=5;
    
    CGFloat labelWidth=self.titleLabel.frame.size.width;
    
    CGFloat labelX=(btnWidth-margin-imgwidth-labelWidth)*0.5;
    self.titleLabel.frame=CGRectMake(labelX, 0, labelWidth, btnHeight);
    
    self.imageView.frame=CGRectMake(CGRectGetMaxX(self.titleLabel.frame)+margin, (btnHeight-imgheight)*0.5,imgwidth , imgheight);

}

@end
